/*
 * ErrorLines.java
 * 
 * Made by Olof Ekelund, Ludvig Gee, Yacoub Sattar 
 * October 19 2012.
 * 
 * Class to write ErrorLines.txt
 * 
 * Version 1.0
 *  
 * Copyright Olof Ekelund, Ludvig Gee, Yacoub Sattar.
 */

import java.util.*;

public class ErrorLines {
	static ArrayList<String> errorLines;
	static String filepath;
	
	ErrorLines(){
		errorLines = new ArrayList();
		filepath = null;
	}
	
public void setFilepath(String f){
		
		f.replaceAll("\\$", "\\\\");
		f += "\\";
		filepath = f;
		
	}
	
	public void addLine(String s){
		errorLines.add(s);
	}
	
	public void printList(){
		for(int i = 0; i < errorLines.size(); i++){
			System.out.println(errorLines.get(i));
		}
	}
	public void writeListToFile(){
		try{
			Formatter fout = new Formatter(filepath + "ErrorLines.txt");
			for(int i = 0; i < errorLines.size(); i++){
				fout.format("%s", errorLines.get(i));
			}
			fout.close();
		}catch(Exception e){
			System.out.println("File not found");
		}
	}
	public int getListSize(){
		return errorLines.size();
	}
}
